/**
 * // Definition for a Node.
 * function Node(val,children) {
 *    this.val = val;
 *    this.children = children;
 * };
 */

/**
 * @param {Node|null} root
 * @return {number[][]}
 */
 var levelOrder = function(root) {
    let res = []
    let queue = []
    if(root ==null){
        return res
    }
    queue.unshift(root)
    while(queue.length!==0){
        let curLevel = [];
        let len = queue.length
        for(let i= 0;i<len;i++){
            let node = queue.pop()
            curLevel.push(node.val)
            for(let item of node.children){
                queue.unshift(item)
            }
           
        }
        res.push(curLevel)
    }
    return res;
};